﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class BalanceCenter_NewsDetail : PageBase
{
    public string NewNews = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        int id = -1;
        try
        {
            id = ShoveEL._Convert.StrToInt(this.Request["id"], -1);
        }
        catch
        {
            this.Response.Redirect("News.aspx", true);

            return;
        }

        if (id < 1)
        {
            this.Response.Redirect("News.aspx", true);

            return;
        }

        BindData(id);
    }

    #region Web 窗体设计器生成的代码

    override protected void OnInit(EventArgs e)
    {
        isRequestLogin = true;
        RequestLoginPage = "BalanceCenter/NewsDetail.aspx?id=" + this.Request["id"];

        base.OnInit(e);
    }

    #endregion

    private void BindData(int id)
    {
        NewNews = PublicFunction.GetOptionsBin("滚动新闻");

        DataTable dt = DAL.Tables.T_News.Select("*", "isShow=1 and id = " + id.ToString(), "[DateTime] desc");

        if (dt == null)
        {
            PublicFunction.GoError(ErrorNumber.DataReadWrite, "数据读写错误", this.GetType().BaseType.FullName);

            return;
        }

        if (dt.Rows.Count == 0)
        {
            PublicFunction.GoError(ErrorNumber.NoData, "暂无数据", this.GetType().BaseType.FullName);

            return;
        }

        labTitle.Text = dt.Rows[0]["Title"].ToString();
        labTime.Text = dt.Rows[0]["DateTime"].ToString();
        try
        {
            labContent.Text = ShoveEL._String.Decompress((byte[])dt.Rows[0]["Content"]);
        }
        catch {}
    }
}